//    Copyright (C) Kherty.  All rights reserved.
using System.Windows.Controls;
using OpenLS.Spreadsheet.UI.Internals;
using System.Windows;
using OpenLS.UI;

namespace OpenLS.Spreadsheet.UI
{
    partial class FormattingRulePropertiesResources
    {
        public FormattingRulePropertiesResources()
        {
              InitializeComponent();
        }
        /*
        private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (e.AddedItems == null || e.AddedItems.Count == 0)
                return;
            var combo = (ComboBox)sender;
            var rule = (StandardConditionalFormattingRule) combo.DataContext;
            object o = e.AddedItems[0];
            if (o is string)
            {
                EditRuleStyle(sender, rule);
            }
            else
            {

                rule.DifferentialStyleRecord = ((NamedDifferentialStyleRecord) o).Record;
            }
        }

        private void EditRuleStyle(object sender, StandardConditionalFormattingRule rule)
        {
            var old = rule.DifferentialStyleRecord;
            if (false)
                rule.DifferentialStyleRecord = rule.DifferentialStyleRecord.Clone();
            else
                rule.DifferentialStyleRecord = new DifferentialStyleRecord();
            if (PropertyHelper.ShowPropertiesNonHostedFor(sender as FrameworkElement, rule, new[] { new FormattingRuleStylePropertiesResources() }))
            {
             
            }
            else
            {
                rule.DifferentialStyleRecord = old;
            }
        }
        private void ComboBox_Loaded(object sender, System.Windows.RoutedEventArgs e)
        {
            var combo = (ComboBox)sender;
            var rule = (StandardConditionalFormattingRule)combo.DataContext;
            foreach (NamedDifferentialStyleRecord r in NamedDifferentialStyleRecord.Instances)
            {
                rule.DifferentialStyleRecord = r.Record;
                break;
            }
        }*/

       /* private void FocusTextBox(object sender, System.Windows.RoutedEventArgs e)
        {
            var tb = (TextBox) sender;
            tb.Focus();
            tb.SelectAll();
            

        }

        private void TextBlock_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            ComboBox combo = WindowServices.GetAncestorUsingTemplatedParent<ComboBox>(sender);
            var rule = (StandardConditionalFormattingRule) (combo).DataContext;
            EditRuleStyle(sender, rule);
        }*/
    }
}
